#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include <windows.h>
#include <stdio.h>
#define THREADNUM 3                      //线程数
int sum;

DWORD WINAPI ThreadFunc(LPVOID lpParam)
{
	sum=0;
	int upper;
	memcpy(&upper,lpParam,sizeof(int));
	for(int i=0;i<=upper;i++)
		sum+=i;
    return 0;
} 

int main(int argc, char* argv[])
{
    DWORD dwThreadId; 
    HANDLE hThread; 
    int upper=atoi(argv[1]);
	hThread= CreateThread( 
			NULL,
			0,
			ThreadFunc,
			&upper,
			CREATE_SUSPENDED,
			&dwThreadId);
	ResumeThread(hThread);
	WaitForSingleObject(hThread,1000);
	printf("sum = %d \n",sum);
    
    return 0;
}
